package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class IntToItemTypeConverter implements Converter<Integer, ItemType> {
    public ItemType convert(Integer code){
        if(1==code)
            return ItemType.APARTMENT;
        else if(2==code)
            return ItemType.ROOM;
        throw new IllegalArgumentException("code:"+code+"非法");
    }
}
